<?php ob_start();?>
<html>
<?php 
	$root = $_SERVER['DOCUMENT_ROOT'];
 	include($root.'/standart/head.php');
 	include($root.'/standart/dateHeader.php');
 	include($root.'/standart/checkUser.php');
?>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Start Bootstrap - SB Admin Version 2.0 Demo</title>
    <link href="../css/bootstrap.min.css" rel="stylesheet">
    <link href="../font-awesome/css/font-awesome.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="../css/jquery.cleditor.css" />
    <link href="../css/sb-admin.css" rel="stylesheet">
    <script type="text/javascript" src="../js/jquery-1.10.2.js"></script>
    <script type="text/javascript" src="../js/ajax.js"></script>
	<script type="text/javascript" src="../js/jquery.cleditor.min.js"></script>
  	<script type="text/javascript" src="../js/jquery.cleditor.table.min.js"></script>
  	<script type="text/javascript">
	    $(document).ready(function () { $("#input").cleditor({
	        useCSS:       false, // use CSS to style HTML when possible (not supported in ie)
	        docType:      // Document type contained within the editor
	          '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">',
	        docCSSFile:   // CSS file used to style the document contained within the editor
	          "",
	        bodyStyle:    // style to assign to document body contained within the editor
	          "margin:4px; font:10pt Arial,Verdana; cursor:text"
	      }); 

	    $("#btnGetHtml").click(function () {
		    var selectedVal = document.getElementById('selectBox').value;
		    if(selectedVal != ''){
		    	$("#CONTENT_DATA").val($("#input").val())
			    document.getElementById('submitForm').submit();
		    }
        });

        <?php 
        	if(isset($_GET['selectId'])){
		?>
			document.getElementById('selectBox').value = <?php echo  $_GET['selectId'] ?>;
			callContent(<?php echo  $_GET['selectId'] ?>);
		<?php 
			}
		?>

		parent.unloadPageX();
	   });

	    function callContent(selectedVal){
		    if(selectedVal != ''){
			    url = 'getContent.php?CONTENT_ID='+selectedVal
			    var htmlVal = ajx(url, '');
			    document.getElementById('invisContentView').innerHTML = htmlVal;
			    $('#input').val($('#invisContentView div').html()).blur(); 
		    }else{
		    	$('#input').val('').blur();
		    }
	    }
	</script>
</head>

<body>
    <div id="wrapper">
        <div id="inner-page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">Web Sayfası Ayarları</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            Sabit Alanların Oluşturulması/Değiştirilmesi
                        </div>
                        <div class="panel-body">
                            <div class="row">
                                <div class="col-lg-6">
                                    <form role="form" action="setContent.php" method="post" id="submitForm">
                                    	<div class="form-group">
                                            <label>Alan Bilgisi</label>
                                            <select class="form-control" id="selectBox" name="selectBox" onchange="callContent(this.value)">
                                            	<option value=''>Seçiniz</option>
                                            	<?php 
                                            	$db = connect();
                                            	$stmt ="SELECT ID, CONTENT_NAME
                                            	FROM WEB_CONTENT";
                                            	$res = $db->query($stmt) or die($stmt."<br/><br/>".mysql_error());
                                            	while($row = $res->fetch_assoc()){
                                            		echo '<option value="'.$row['ID'].'">'.$row['CONTENT_NAME'].'</option>';
                                            	}
                                            	$res->close();
                                            	disconnect($db);
                                            	?>
                                            </select>
                                        </div>
                                        <div class="form-group">
                                            <label>Yazı Alanı</label>
                                            <textarea id="input" name="input"></textarea>
                                        </div>
                                        <button type="button" id="btnGetHtml" class="btn btn-default">Kaydet</button>
                                        <textarea id="CONTENT_DATA" name="CONTENT_DATA" style="display: none;"></textarea>
                                    </form>
                                </div>
							</div>
                            <!-- /.row (nested) -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
        </div>
        <!-- /#page-wrapper -->

    </div>
    <!-- /#wrapper -->
	<div id="invisContentView" style="display: none;"></div>
    <!-- Core Scripts - Include with every page -->
    <!-- Page-Level Demo Scripts - Forms - Use for reference -->
</body>

</html>
<?php ob_end_flush(); ?>